<?php

/**
 * @application Automatical Judging System
 * @author deltamaster
 * @copyright Softrank Research Center
 * @version 2.0.0.0
 */

class contest
{
    public $config;
    public $appname = "Automatical Judging System";
    public $copyright = "SoftRank Research Center";
    public $version = "2.1.0.0";

    public function contest()
    {
    	global $lang;
        global $db;
        $query = $db->query("SELECT * FROM `sj_config`");
        for ($i = 0; $i < $db->num_rows($query); $i++)
        {
            $temp[$i] = $db->fetch_array($query);
        }
        foreach ($temp as $item)
        {
            $this->config[$item['name']] = $item['value'];
        }
    }

    public function started()
    {
        $temp = ProcessTime($this->config['starttime']);
        if ($temp['time'] <= time())
            return true;
        else
            return false;
    }

    public function ended()
    {
        $temp = ProcessTime($this->config['endtime']);
        if ($temp['time'] <= time())
            return true;
        else
            return false;
    }

    public function totaltime()
    {
        $start = ProcessTime($this->config['starttime']);
        $end = ProcessTime($this->config['endtime']);
        return $end['time'] - $start['time'];
    }

    public function timepassed()
    {
        $start = ProcessTime($this->config['starttime']);
        return time() - $start['time'];
    }
}

?>